home *** CD-ROM | disk | FTP | other *** search
- #ifndef MDUSER_DLL
-
- #include <stdio.h>
- #include "MDUserImports.h"
-
- HINSTANCE hMDUSER = NULL;
- bool MDUserDllLoaded = false;
-
- MD_FlagReloadUsersP MD_FlagReloadUsers;
- MD_InitMessageInfoP MD_InitMessageInfo;
- MD_GetSharedUserInfoP MD_GetSharedUserInfo;
- MD_VerifyMessageInfoP MD_VerifyMessageInfo;
- MD_SpoolMessageP MD_SpoolMessage;
- MD_GetDomainNamesP MD_GetDomainNames;
- MD_GetDomainCountP MD_GetDomainCount;
- MD_GetDomainNameUsingIPP MD_GetDomainNameUsingIP;
- MD_FilterStringP MD_FilterString;
- MD_FilterUserInfoP MD_FilterUserInfo;
- MD_RegisterWindowP MD_RegisterWindow;
- MD_UnregisterWindowP MD_UnregisterWindow;
- MD_ReloadUsersP MD_ReloadUsers;
- MD_GetAppDirP MD_GetAppDir;
- MD_SetIsMDConfigP MD_SetIsMDConfig;
- MD_GetDBPathP MD_GetDBPath;
- MD_InitUserInfoP MD_InitUserInfo;
- MD_AddUserP MD_AddUser;
- MD_ChangeUserP MD_ChangeUser;
- MD_DeleteUserP MD_DeleteUser;
- MD_VerifyUserInfoP MD_VerifyUserInfo;
- MD_UserCountP MD_UserCount;
- MD_IsProVersionP MD_IsProVersion;
- MD_FindFirstP MD_FindFirst;
- MD_FindNextP MD_FindNext;
- MD_FindCloseP MD_FindClose;
- MD_FindFirstRuleP MD_FindFirstRule;
- MD_FindNextRuleP MD_FindNextRule;
- MD_GetEditIMAPRulesP MD_GetEditIMAPRules;
- MD_SetEditIMAPRulesP MD_SetEditIMAPRules;
- MD_ReadRuleP MD_ReadRule;
- MD_MoveRuleUpP MD_MoveRuleUp;
- MD_MoveRuleDownP MD_MoveRuleDown;
- MD_RuleStructToRuleStringP MD_RuleStructToRuleString;
- MD_RuleStringToRuleStructP MD_RuleStringToRuleStruct;
- MD_AddRuleP MD_AddRule;
- MD_DeleteRuleP MD_DeleteRule;
- MD_ChangeRuleP MD_ChangeRule;
- MD_GetIMAPFoldersP MD_GetIMAPFolders;
- MD_CreateIMAPFolderP MD_CreateIMAPFolder;
- MD_ValidateUserP MD_ValidateUser;
- MD_LogonUserP MD_LogonUser;
- MD_GetByAliasP MD_GetByAlias;
- MD_UserExistsP MD_UserExists;
- MD_GetByEmailP MD_GetByEmail;
- MD_GetByFullNameP MD_GetByFullName;
- MD_GetByMailboxP MD_GetByMailbox;
- MD_GetByMailDirP MD_GetByMailDir;
- MD_GetFreeP MD_GetFree;
- MD_GetUserInfoP MD_GetUserInfo;
- MD_SetUserInfoP MD_SetUserInfo;
- MD_GetEmailP MD_GetEmail;
- MD_GetMailboxP MD_GetMailbox;
- MD_SetMailboxP MD_SetMailbox;
- MD_GetDomainP MD_GetDomain;
- MD_SetDomainP MD_SetDomain;
- MD_GetFullNameP MD_GetFullName;
- MD_SetFullNameP MD_SetFullName;
- MD_GetMailDirP MD_GetMailDir;
- MD_SetMailDirP MD_SetMailDir;
- MD_GetPasswordP MD_GetPassword;
- MD_SetPasswordP MD_SetPassword;
- MD_GetAutoDecodeP MD_GetAutoDecode;
- MD_SetAutoDecodeP MD_SetAutoDecode;
- MD_GetIsForwardingP MD_GetIsForwarding;
- MD_SetIsForwardingP MD_SetIsForwarding;
- MD_GetAllowAccessP MD_GetAllowAccess;
- MD_SetAllowAccessP MD_SetAllowAccess;
- MD_GetAllowChangeViaEmailP MD_GetAllowChangeViaEmail;
- MD_SetAllowChangeViaEmailP MD_SetAllowChangeViaEmail;
- MD_GetKeepForwardedMailP MD_GetKeepForwardedMail;
- MD_SetKeepForwardedMailP MD_SetKeepForwardedMail;
- MD_GetHideFromEveryoneP MD_GetHideFromEveryone;
- MD_SetHideFromEveryoneP MD_SetHideFromEveryone;
- MD_GetEncryptMailP MD_GetEncryptMail;
- MD_SetEncryptMailP MD_SetEncryptMail;
- MD_GetApplyQuotasP MD_GetApplyQuotas;
- MD_SetApplyQuotasP MD_SetApplyQuotas;
- MD_GetEnableMultiPOPP MD_GetEnableMultiPOP;
- MD_SetEnableMultiPOPP MD_SetEnableMultiPOP;
- MD_GetLocalOnlyP MD_GetLocalOnly;
- MD_SetLocalOnlyP MD_SetLocalOnly;
- MD_GetMaxDiskSpaceP MD_GetMaxDiskSpace;
- MD_SetMaxDiskSpaceP MD_SetMaxDiskSpace;
- MD_GetMaxMessageCountP MD_GetMaxMessageCount;
- MD_SetMaxMessageCountP MD_SetMaxMessageCount;
- MD_GetForwardingInfoP MD_GetForwardingInfo;
- MD_SetForwardingInfoP MD_SetForwardingInfo;
- MD_GetAutoRespInfoP MD_GetAutoRespInfo;
- MD_SetAutoRespInfoP MD_SetAutoRespInfo;
- MD_EraseAutoRespP MD_EraseAutoResp;
- MD_UpdateAutoRespDomainsP MD_UpdateAutoRespDomains;
- MD_GetMailFormatP MD_GetMailFormat;
- MD_SetMailFormatP MD_SetMailFormat;
- MD_GetSignatureFileP MD_GetSignatureFile;
- MD_SetSignatureFileP MD_SetSignatureFile;
- MD_GetFileCountP MD_GetFileCount;
- MD_GetDirSizeP MD_GetDirSize;
- MD_GetWebConfigBitP MD_GetWebConfigBit;
- MD_GetWebConfigBitsP MD_GetWebConfigBits;
- MD_SetWebConfigBitP MD_SetWebConfigBit;
- MD_SetWebConfigBitsP MD_SetWebConfigBits;
- MD_IsDynamicPasswordStrP MD_IsDynamicPasswordStr;
- MD_GetMaxUIDLCountP MD_GetMaxUIDLCount;
- MD_SetMaxUIDLCountP MD_SetMaxUIDLCount;
- MD_GetMaxMessageSizeP MD_GetMaxMessageSize;
- MD_SetMaxMessageSizeP MD_SetMaxMessageSize;
- MD_AddToLdapAddrBookP MD_AddToLdapAddrBook;
-
- #define GET_FUNC(s) s## = (s##P) GetProcAddress(hMDUSER, #s); result &= (s## != NULL);
-
- bool LoadMDUserDll(char* MDUserDll, bool LoadUsers, bool IgnoreFail)
- {
- int Num;
- return LoadMDUserDll(Num, MDUserDll, LoadUsers, IgnoreFail);
- }
-
- bool LoadMDUserDll(int& Result, char* MDUserDll, bool LoadUsers, bool IgnoreFail)
- {
- Result = 0;
-
- if (MDUserDll == NULL)
- {
- char DllPath[MAX_PATH];
- GetModuleFileName(NULL, DllPath, sizeof(DllPath));
- char* ptr = strrchr(DllPath, '\\');
- if (ptr) ptr[0] = '\0';
-
- char SetupFile[MAX_PATH+1];
- sprintf(SetupFile, "%s\\"MDUSERDLL_DEFMDAEMONINIDB, DllPath);
-
- char DllType[16];
- GetPrivateProfileString("Advanced", "UserDllType", "", DllType, sizeof(DllType), SetupFile);
-
- char Dll[MAX_PATH];
- sprintf(Dll, "%s\\MDUser%s.dll", DllPath, DllType);
-
- hMDUSER = LoadLibrary(Dll);
- }
- else
- hMDUSER = LoadLibrary(MDUserDll);
-
- if (hMDUSER == NULL)
- {
- Result = GetLastError();
- return false;
- }
-
- bool result = true;
-
- GET_FUNC(MD_FlagReloadUsers);
- GET_FUNC(MD_InitMessageInfo)
- GET_FUNC(MD_GetSharedUserInfo)
- GET_FUNC(MD_VerifyMessageInfo)
- GET_FUNC(MD_SpoolMessage)
- GET_FUNC(MD_GetDomainNames)
- GET_FUNC(MD_GetDomainCount)
- GET_FUNC(MD_GetDomainNameUsingIP)
- GET_FUNC(MD_FilterString)
- GET_FUNC(MD_FilterUserInfo)
- GET_FUNC(MD_RegisterWindow)
- GET_FUNC(MD_UnregisterWindow)
- GET_FUNC(MD_ReloadUsers)
- GET_FUNC(MD_GetAppDir)
- GET_FUNC(MD_SetIsMDConfig)
- GET_FUNC(MD_GetDBPath)
- GET_FUNC(MD_InitUserInfo)
- GET_FUNC(MD_AddUser)
- GET_FUNC(MD_ChangeUser)
- GET_FUNC(MD_DeleteUser)
- GET_FUNC(MD_VerifyUserInfo)
- GET_FUNC(MD_UserCount)
- GET_FUNC(MD_IsProVersion)
- GET_FUNC(MD_FindFirst)
- GET_FUNC(MD_FindNext)
- GET_FUNC(MD_FindClose)
- GET_FUNC(MD_FindFirstRule)
- GET_FUNC(MD_FindNextRule)
- GET_FUNC(MD_GetEditIMAPRules)
- GET_FUNC(MD_SetEditIMAPRules)
- GET_FUNC(MD_ReadRule)
- GET_FUNC(MD_MoveRuleUp)
- GET_FUNC(MD_MoveRuleDown)
- GET_FUNC(MD_RuleStringToRuleStruct)
- GET_FUNC(MD_RuleStructToRuleString)
- GET_FUNC(MD_AddRule)
- GET_FUNC(MD_DeleteRule)
- GET_FUNC(MD_ChangeRule)
- GET_FUNC(MD_GetIMAPFolders)
- GET_FUNC(MD_CreateIMAPFolder)
- GET_FUNC(MD_ValidateUser)
- GET_FUNC(MD_LogonUser)
- GET_FUNC(MD_GetByAlias)
- GET_FUNC(MD_UserExists)
- GET_FUNC(MD_GetByEmail)
- GET_FUNC(MD_GetByFullName)
- GET_FUNC(MD_GetByMailbox)
- GET_FUNC(MD_GetByMailDir)
- GET_FUNC(MD_GetFree)
- GET_FUNC(MD_GetUserInfo)
- GET_FUNC(MD_SetUserInfo)
- GET_FUNC(MD_GetEmail)
- GET_FUNC(MD_GetMailbox)
- GET_FUNC(MD_SetMailbox)
- GET_FUNC(MD_GetDomain)
- GET_FUNC(MD_SetDomain)
- GET_FUNC(MD_GetFullName)
- GET_FUNC(MD_SetFullName)
- GET_FUNC(MD_GetMailDir)
- GET_FUNC(MD_SetMailDir)
- GET_FUNC(MD_GetPassword)
- GET_FUNC(MD_SetPassword)
- GET_FUNC(MD_GetAutoDecode)
- GET_FUNC(MD_SetAutoDecode)
- GET_FUNC(MD_GetIsForwarding)
- GET_FUNC(MD_SetIsForwarding)
- GET_FUNC(MD_GetAllowAccess)
- GET_FUNC(MD_SetAllowAccess)
- GET_FUNC(MD_GetAllowChangeViaEmail)
- GET_FUNC(MD_SetAllowChangeViaEmail)
- GET_FUNC(MD_GetKeepForwardedMail)
- GET_FUNC(MD_SetKeepForwardedMail)
- GET_FUNC(MD_GetHideFromEveryone)
- GET_FUNC(MD_SetHideFromEveryone)
- GET_FUNC(MD_GetEncryptMail)
- GET_FUNC(MD_SetEncryptMail)
- GET_FUNC(MD_GetApplyQuotas)
- GET_FUNC(MD_SetApplyQuotas)
- GET_FUNC(MD_GetEnableMultiPOP)
- GET_FUNC(MD_SetEnableMultiPOP)
- GET_FUNC(MD_GetLocalOnly)
- GET_FUNC(MD_SetLocalOnly)
- GET_FUNC(MD_GetMaxDiskSpace)
- GET_FUNC(MD_SetMaxDiskSpace)
- GET_FUNC(MD_GetMaxMessageCount)
- GET_FUNC(MD_SetMaxMessageCount)
- GET_FUNC(MD_GetForwardingInfo)
- GET_FUNC(MD_SetForwardingInfo)
- GET_FUNC(MD_GetAutoRespInfo)
- GET_FUNC(MD_SetAutoRespInfo)
- GET_FUNC(MD_EraseAutoResp)
- GET_FUNC(MD_UpdateAutoRespDomains)
- GET_FUNC(MD_GetMailFormat)
- GET_FUNC(MD_SetMailFormat)
- GET_FUNC(MD_GetSignatureFile)
- GET_FUNC(MD_SetSignatureFile)
- GET_FUNC(MD_GetFileCount)
- GET_FUNC(MD_GetDirSize)
- GET_FUNC(MD_GetWebConfigBit)
- GET_FUNC(MD_GetWebConfigBits)
- GET_FUNC(MD_SetWebConfigBit)
- GET_FUNC(MD_SetWebConfigBits)
- GET_FUNC(MD_IsDynamicPasswordStr)
- GET_FUNC(MD_GetMaxUIDLCount)
- GET_FUNC(MD_SetMaxUIDLCount)
- GET_FUNC(MD_GetMaxMessageSize)
- GET_FUNC(MD_SetMaxMessageSize)
- GET_FUNC(MD_AddToLdapAddrBook)
-
- if (!result)
- {
- if (!IgnoreFail)
- FreeMDUserDll();
- Result = 1;
- }
- else
- MDUserDllLoaded = true;
-
- if (LoadUsers)
- {
- if (result || IgnoreFail)
- MD_ReloadUsers();
- }
-
- return result;
- }
-
- void FreeMDUserDll()
- {
- MDUserDllLoaded = false;
-
- if (hMDUSER != NULL)
- FreeLibrary(hMDUSER), hMDUSER = NULL;
- }
-
- #endif